import { defineStore } from "pinia"
import axios from 'axios';
import { nanoid } from 'nanoid/non-secure';
export const useTalkStore = defineStore("talk", {
  actions: {
    async getAPic() {
      let res = await axios.get("https://v2.xxapi.cn/api/wallpaper")
      console.log("@", res.data.data)
      let obj = { id: nanoid(), src: res.data.data }
      this.talkList.unshift(obj)
    }
  },
  //真正存储数据的地方
  state() {
    return {
      talkList: JSON.parse(localStorage.getItem("talkStore") as string) || []

    }
  }
})